package net.maku.system.facade;


import net.maku.system.api.facade.SysUserFacade;
import net.maku.system.convert.SysUserConvert;
import net.maku.system.dao.SysUserDao;
import net.maku.system.entity.SysUserEntity;
import net.maku.system.model.vo.SysUserVO;
import net.maku.system.service.SysUserService;
import org.springframework.stereotype.Component;

@Component
public class SysUserFacadeImpl implements SysUserFacade {

    private final SysUserService sysUserService;

    private final SysUserDao sysUserDao;

    public SysUserFacadeImpl(SysUserService sysUserService, SysUserDao sysUserDao) {
        this.sysUserService = sysUserService;
        this.sysUserDao = sysUserDao;
    }

    @Override
    public SysUserVO getByMobile(String mobile) {
        return sysUserService.getByMobile(mobile);
    }

    @Override
    public SysUserVO selectById(Long userId) {
        SysUserEntity byId = sysUserService.getById(userId);
        return SysUserConvert.INSTANCE.convert(byId);
    }

    @Override
    public SysUserVO getByUsername(String username) {
        SysUserEntity byUsername = sysUserDao.getByUsername(username);
        return SysUserConvert.INSTANCE.convert(byUsername);
    }

}
